from typing import List


class Solution:
    def findNumberIn2DArray(self, matrix: List[List[int]], target: int) -> bool:
        if(len(matrix)==0):return False

        m = len(matrix)
        n = len(matrix[0])

        row = 0
        col = n-1
        while row<m and col>=0:
            if matrix[row][col]==target:
                return True

            if matrix[row][col]>target:
                col -= 1
            else:
                row += 1
        return False